// 关于课程列表的vuex
import { getCourseList } from '../../api/course'
const CourseStore = {
    namespaced: true,
    state: {
        searchText: "",
        CategoryOne: "",
        CategoryTwo: "",
        CategoryThree: "",
        courseList: [], //课程列表
        pageStart: 1, //当前页码
        pageSize: 3, //一页条数
        count: 0, //数据总条数
    },
    mutations: {
        // 改变搜索数据
        changeSea(state, obj) {
            console.log(obj)
            state.searchText = obj.sea;
            state.CategoryOne = obj.cateOne;
            state.CategoryTwo = obj.cateTwo;
            state.CategoryThree = obj.cateThree;
        },
        // 改变当前页码
        changePage(state, page) {
            state.pageStart = page;
        },
        // actions请求回来的数据 赋值给state
        changeData(state, res) {
            state.courseList = res.data.data.list;
            state.count = res.data.data.count;
            state.pageSize = res.data.data.pageSize;
        }
    },
    actions: {
        // 发送请求 课程列表
        async getListApi({ commit }, data) {
            var res = await getCourseList(data)
            console.log(res);
            commit("changeData", res)
        }
    },
    getters: {}
}
export default CourseStore